﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CWB.Common.Utilities
{
    public class VoiceTools
    {
        public static VoiceConvertResult VoiceRequestResult(string result)
        {
            char[] para = { '&' };
            string[] res = result.Split(para);
            if (res.Length == 3)
            {
                VoiceConvertResult vcResult = new VoiceConvertResult()
                {
                    ResultCode = res[0],
                    ResultString = res[1],
                    ResultId = Convert.ToInt32(res[2])
                };
                return vcResult;
            }
            else
            {
                throw new Exception("Voice convert return result format incorrect.");
            }
        }

        public static VoiceConvertResult VoiceConvertResult(string result)
        {
            char[] para = { '&' };
            string[] res = result.Split(para);
            VoiceConvertResult vcResult = new VoiceConvertResult() { };

            if (res.Length == 5)
            {
                vcResult = new VoiceConvertResult()
                {
                    ResultCode = res[0],
                    ResultString = res[1],
                    ResultStatus = Convert.ToInt32(res[2]),
                    ResultPath = res[4]
                };
            }
            else if (res.Length == 4)
            {
                vcResult = new VoiceConvertResult()
                {
                    ResultCode = res[0],
                    ResultString = res[1],
                    ResultStatus = Convert.ToInt32(res[2]),
                };
            }
            else
            {
                throw new Exception("Voice convert return result format incorrect.");
            }
            return vcResult;
        }
    }

    public class VoiceConvertResult
    {
        public string ResultCode;
        public string ResultString;
        public int ResultId;

        public int ResultStatus;
        public string ResultPath;
    }
}
